let URL = "http://localhost:8080";

function myAjax(url, data, type) {
    let result = null;
    let user = {loginUsername: sessionStorage.getItem("username")};
    console.log(user);
    $.ajax({
        url: URL + url,
        data: Object.assign(user, data),
        type: type,
        async: false,
        xhrFields: {
            withCredentials: true //允许跨域带Cookie
        },

        dataType: 'json',
        success: function (data) {
            if (data.result == -1) {
                alert("你为登录，即将跳转登录页面");
                window.open("/canyin07-1224-xadmin/html/login.html");
            } else {
                console.log(data, 11);
                result = data;
            }

        }
    });
    return result;
}

function myFileAjax(url, data, type) {
    let result = null;
    $.ajax({
        url: URL + url,
        data: data,
        type: type,
        async: false,
        dataType: 'json',

        contentType: false,
        processData: false,
        xhrFields: {
            withCredentials: true //允许跨域带Cookie
        },
        success: function (data) {
            if (data.result == -1) {
                alert("你为登录，即将跳转登录页面");
                window.open("/html/login.html");
            } else {
                console.log(data, 11);
                result = data;
            }
        }
    });
    return result;
}